/*
 * Copyright 2012 Clement Sannicolo <clement.sannicolo@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

Ext.define('Nutrient.view.food.form.Edit',
{
	extend: 'Ext.form.Panel',
	alias: 'widget.nutrient.food.form.edit',

	requires: [
	    'Ext.ux.tab.TreeTabPanel',
	    'Ext.form.Panel'
	],

	layout: 'fit',

	border: false,
	items: [{
		itemId: 'treetabpanel',
		xtype: 'tab.treetabpanel', 
		border: false,
		treepanel: {
			width: 120
		},
		contentpanel: {
			itemId: 'formpanel',
			xtype: 'form',
			defaults: {
				bodyPadding: 10
			},
			fieldDefaults: {
				labelAlign: 'top'
			}
		},
		children: [{
			itemId: 'card-general',
			title: 'General',
			iconCls: 'icon-setting',
			layout: 'anchor',
			defaults: {
				anchor: '100%'
			},
			items: [{
				xtype: 'textfield',
				name: 'name',
				fieldLabel: 'Name',
				vtype: 'name',
				allowBlank: false
			}]
		}, {
			itemId: 'card-category',
			title: 'Famille',
			html: 'famille'
		}, {
			itemId: 'card-energy',
			title: 'Energie',
			layout: 'anchor',
			defaults: {
				xtype: 'textfield',
				anchor: '100%',
				vtype: 'numeric',
				allowBlank: false
			},
			items: [{
				name: 'energy',
				fieldLabel: 'Energie (kcal)'
			}]
		}, {
			itemId: 'card-components',
			title: 'Composition',
			layout: 'anchor',
			defaults: {
				border: false,
				flex: 1,
				layout: 'anchor'
			},
			layout: 'hbox',
			items: [{
				defaults: {
					xtype: 'textfield',
					anchor: '-10',
					vtype: 'numeric',
					allowBlank: false
				},
				items: [{
					name: 'protein',
					fieldLabel: 'Protéines (g)'
				}, {
					name: 'water',
					fieldLabel: 'Eau (g)'
				}, {
					name: 'alcohol',
					fieldLabel: 'Alcool (g)'
				}, {
					name: 'fiber',
					fieldLabel: 'Fibres (g)'
				}]
			}, {
				defaults: {
					xtype: 'textfield',
					anchor: '-10',
					vtype: 'numeric',
					allowBlank: false
				},
				items: [{
					name: 'carbohydrates',
					fieldLabel: 'Glucides (g)'
				}, {
					name: 'starch',
					fieldLabel: 'Amidon (g)'
				}, {
					name: 'sugar',
					fieldLabel: 'Sucre (g)'
				}]
			}, {
				defaults: {
					xtype: 'textfield',
					anchor: '100%',
					vtype: 'numeric',
					allowBlank: false
				},
				items: [{
					name: 'fat',
					fieldLabel: 'Lipides (g)'
				}, {
					name: 'fattyAcidsSaturated',
					fieldLabel: 'AG saturés (g)'
				}, {
					name: 'fattyAcidsMonounsaturated',
					fieldLabel: 'AG mono-insaturés (g)'
				}, {
					name: 'fattyAcidsPolyunsaturated',
					fieldLabel: 'AG poly-insaturés (g)'
				}]
			}]
		}, {
			itemId: 'card-minerals',
			title: 'Minéraux',
			layout: 'anchor',
			defaults: {
				border: false,
				flex: 1,
				layout: 'anchor'
			},
			layout: 'hbox',
			items: [{
				defaults: {
					xtype: 'textfield',
					anchor: '-10',
					vtype: 'numeric',
					allowBlank: false
				},
				items: [{
					name: 'calcium',
					fieldLabel: 'Calcium (mg)'
				}, {
					name: 'copper',
					fieldLabel: 'Cuivre (mg)'
				}, {
					name: 'iodine',
					fieldLabel: 'Iode (µg)'
				}, {
					name: 'iron',
					fieldLabel: 'Fer (mg)'
				}]
			}, {
				defaults: {
					xtype: 'textfield',
					anchor: '-10',
					vtype: 'numeric',
					allowBlank: false
				},
				items: [{
					name: 'magnesium',
					fieldLabel: 'Magnesium (mg)'
				}, {
					name: 'manganese',
					fieldLabel: 'Manganese (mg)'
				}, {
					name: 'phosphorus',
					fieldLabel: 'Phosphore (mg)'
				}, {
					name: 'potassium',
					fieldLabel: 'Potassium (mg)'
				}]
			}, {
				defaults: {
					xtype: 'textfield',
					anchor: '100%',
					vtype: 'numeric',
					allowBlank: false
				},
				items: [{
					name: 'selenium',
					fieldLabel: 'Selenium (µg)'
				}, {
					name: 'sodium',
					fieldLabel: 'Sodium (mg)'
				}, {
					name: 'zinc',
					fieldLabel: 'Zinc (mg)'
				}]
			}]
		}, {
			itemId: 'card-vitamins',
			title: 'Vitamines',
			layout: 'anchor',
			defaults: {
				border: false,
				flex: 1,
				layout: 'anchor'
			},
			layout: 'hbox',
			items: [{
				defaults: {
					xtype: 'textfield',
					anchor: '-10',
					vtype: 'numeric',
					allowBlank: false
				},
				items: [{
					name: 'vitaminA',
					fieldLabel: 'Vitamine A (µg)'
				}, {
					name: 'vitaminB1',
					fieldLabel: 'Vitamine B1 (mg)'
				}, {
					name: 'vitaminB2',
					fieldLabel: 'Vitamine B2 (mg)'
				}, {
					name: 'vitaminB3',
					fieldLabel: 'Vitamine B3 (mg)'
				}]
			}, {
				defaults: {
					xtype: 'textfield',
					anchor: '-10',
					vtype: 'numeric',
					allowBlank: false
				},
				items: [{
					name: 'vitaminB5',
					fieldLabel: 'Vitamine B5 (mg)'
				}, {
					name: 'vitaminB6',
					fieldLabel: 'Vitamine B6 (mg)'
				}, {
					name: 'vitaminB9',
					fieldLabel: 'Vitamine B9 (µg)'
				}, {
					name: 'vitaminB12',
					fieldLabel: 'Vitamine B12 (µg)'
				}]
			}, {
				defaults: {
					xtype: 'textfield',
					anchor: '100%',
					vtype: 'numeric',
					allowBlank: false
				},
				items: [{
					name: 'vitaminC',
					fieldLabel: 'Vitamine C (mg)'
				}, {
					name: 'vitaminD',
					fieldLabel: 'Vitamine D (µg)'
				}, {
					name: 'vitaminE',
					fieldLabel: 'Vitamine E (mg)'
				}]
			}]
		}]
	}]
});